puts "INFO: Running script [info script]\n"


#################################################
# Design Mode
#################################################
setDesignMode -process 110

if {$FLOW_EFFORT == "extreme"} {
		setLimitedAccessFeature flow_effort_xtreme 1
}
setDesignMode -flowEffort $FLOW_EFFORT

set delaycal_enable_high_fanout true
#################################################
# Place Mode
#################################################
setPlaceMode -maxRouteLayer 6
setPlaceMode -place_detail_legalization_inst_gap 2
setPlaceMode -placeIoPins false
setPlaceMode -place_detail_swap_eeq_cells true
setPlaceMode -place_global_ignore_scan true
setPlaceMode -place_detail_honor_inst_pad true
setPlaceMode -place_global_uniform_density true
setPlaceMode -place_global_max_density 0.35

#################################################
# Opt Mode
#################################################
setOptMode -honorFence true
setOptMode -allEndPoints true
setOptMode -maxDensity 0.4
setOptMode -maxLocalDensity 0.4
setOptMode -reclaimArea true
setOptMode -fixFanoutLoad true
setOptMode -verbose true
setOptMode -timeDesignNumPaths 500
setOptMode -powerEffort none
setOptMode -usefulSkew true
setOptMode -usefulSkewPreCTS false
setOptMode -usefulSkewPostRoute true
setOptMode -usefulSkewCCOpt extreme

#################################################
# Extract RC Mode
#################################################
if {$current_step == "place"} {
		setExtractRCMode -layerIndependent 1
		setExtractRCMode -defViaCap true
		setExtractRCMode -engine preRoute
}
if {$current_step == "route_opt" || $current_step == "std_filler"} {
		setExtractRCMode -engine postRoute
		setExtractRCMode -effortLevel medium
}

#################################################
# Analysis Mode
#################################################
setAnalysisMode -analysisType onChipVariation -cppr both
setLimitedAccessFeature ediUsePreRouteGigaOpt 1

setAnalysisMode -analysisType onChipVariation
setAnalysisMode -clockPropagation sdcControl
setAnalysisMode -asyncChecks async
#setAnalysisMode -timeBorrowing true
setAnalysisMode -honorClockDomains false

#################################################
# Route Mode
#################################################
setRouteMode -earlyGlobalMinRouteLayer 2 -earlyGlobalMaxRouteLayer 5
setRouteMode -minRouteLayer 2 -maxRouteLayer 5

# preRoute routing estimation setting
setRouteMode -earlyGlobalLocalRouteEffort 1.2
setRouteMode -earlyGlobalBetterTransitionViaModeling false
setRouteMode -earlyGlobalSupplyScaleFactorH 1
setRouteMode -earlyGlobalSupplyScaleFactorV 1

#################################################
# Nano Route Mode
#################################################
setNanoRouteMode -routeBottomRoutingLayer 2 -routeTopRoutingLayer 5
setNanoRouteMode -routeWithTimingDriven true
setNanoRouteMode -routeWithSiDriven true
setNanoRouteMode -drouteEndIteration default
setNanoRouteMode -drouteExpRemoveDanglingPatch true
setNanoRouteMode -droutePostRouteSwapVia none

if {$current_step == "ccopt"} {
		setNanoRouteMode -drouteUseMultiCutViaEffort high
}
if {$current_step == "route"} {
		setNanoRouteMode -drouteUseMultiCutViaEffort default
}


# Antenna fix
if {$ROUTE_AUTO_ANTENNA_FIXING} {
		setNanoRouteMode -drouteFixAntenna true
		setNanoRouteMode -routeInsertAntennaDiode true
		setNanoRouteMode -routeAntennaCellName [dbGet head.libCells.name ANTHM]
		setNanoRouteMode -routeInsertDiodeForClockNets true
}

#################################################
# Delay Calculate Mode
#################################################
setDelayCalMode -engine aae
if {$current_step == "route" || $current_step == "route_opt" || $current_step == "std_filler"} {
		setDelayCalMode -SIAware true
} else {
		setDelayCalMode -SIAware false
}

setDelayCalMode -equivalent_waveform_model propagation
setDelayCalMode -ewm_type simulation

if {$current_step == "route_opt" || $current_step == "std_filler"} {
		setDelayCalMode -signoff true
		setDelayCalMode -siMode opt_signoff
}

#################################################
# Congestion Setting
#################################################
setPlaceMode -congEffort $CONGESTION_EFFORT
setPlaceMode -place_global_cong_effort $CONGESTION_EFFORT

#################################################
# Timing Setting
#################################################
if {$TIMING_EFFORT == "low"} {
		setPlaceMode -place_global_timing_effort medium
}
if {$TIMING_EFFORT == "high"} {
		setPlaceMode -place_global_timing_effort medium
}

setOptMode -effort $TIMING_EFFORT


#################################################
# Power Setting
#################################################
setDesignMode -powerEffort $POWER_EFFORT
setOptMode -powerEffort $POWER_EFFORT

#################################################
# CCOPT property
#################################################
set_ccopt_property update_io_latency false
set_ccopt_property integration native
set_ccopt_property post_conditioning_route_select_entire_clock_tree true
set_ccopt_property route_type_override_preferred_routing_layer_effort none
set_ccopt_property force_nanoroute_single_threaded false

#################################################
# SI Setting
#################################################
setSIMode -analysisType AAE 
setSIMode -si_reselection all
setSIMode -separate_delta_delay_on_data true
setSIMode -individual_attacker_simulation_filtering true
setSIMode -delta_delay_annotation_mode lumpedOnNet
setSIMode -input_glitch_vh_threshold 0.2
setSIMode -input_glitch_vl_threshold 0.2
setSIMode -use_infinite_TW true

#################################################
# dont use cell
#################################################
source -e -v user_scripts/dont_use.tcl


#################################################
# Hold fix
#################################################
setOptMode -holdTargetSlack 0
#setOptMode -holdSlackFixingThreshold -0.5
setOptMode -holdSlackFixingThreshold -5.0
setOptMode -fixHoldAllowSetupTnsDegrade true
#setOptMode -ignorePathGroupsForHold {IN2REG}
setOptMode -ignorePathGroupsForHold {}
#setOptMode -checkRoutingCongeation true

set HOLD_FIX_CELL ""
lappend HOLD_FIX_CELL [dbGet head.libCells.name $HOLD_FIX_DELAY_CEL]
lappend HOLD_FIX_CELL [dbGet head.libCells.name $HOLD_FIX_BUFFER_CEL]
setOptMode -holdFixingCells [join $HOLD_FIX_CELL]

#################################################
# Design Rule
#################################################
set_interactive_constraint_modes [all_constraint_modes -active]
set_max_transition 0.64 [current_design]
set_max_capacitance 0.4 [current_design]
set_max_fanout 32 [current_design]
set_interactive_constraint_modes {}

setOptMode -maxLength 200


# dont touch for click & delay cell
dbset [dbget -p top.insts.name *delay*].dontTouch true
dbset [dbget -p top.insts.cell.name DEL1M4HM].dontTouch true
dbset [dbget -p top.insts.name *Delay*].dontTouch true
dbset [dbget -p top.insts.name *click*].dontTouch true
dbset [dbget -p top.insts.name *Click*].dontTouch true
#dbset [dbget -p top.nets.name DEL1M4HM].dontTouch true
#dbset [dbget -p top.nets.name PORE].skipRouting 1
#dbset [dbget -p top.insts.instTerms.name */DEL1M4HM].net.dontTouch true
#foreach net [dbget [dbget -p top.insts.instTerms.name */PORE].net.name ] {
#		if {$net != "0x0"} {
#				dbset  [dbget -p top.nets.name $net].skipRouting 1
#		}
#}

set_global report_timing_format $TIMING_REPORT_FORMAT

puts "INFO: Completed script [info script]\n"

